package com.example.personal.mvvm.viewmodel

import androidx.lifecycle.MutableLiveData
import com.example.personal.api.PersonalApiManager
import com.gsafety.library.Base.BaseViewModel
import com.gsafety.libraryktx.bean.LoadState
import com.gsafety.libraryktx.expand.enqueue
import com.gsafety.libraryktx.manager.UserManager
import com.gsafety.libraryktx.net.api.request.RequestParamsManager

class SecretViewModel:BaseViewModel() {
    var loadState = MutableLiveData<LoadState>()
    fun updatePassword(oldPass:String,newPass:String){
        var id=UserManager.getInstance().getUser()?.userId
        enqueue(PersonalApiManager.loginapiService.updatePassword(RequestParamsManager.updatePassword(id!!,oldPass,newPass)),onSuccess={ result ->
            loadState.value = LoadState.Success()
        },onFail={ error->
            loadState.value = LoadState.Fail(error?: "")
        })
    }


}